package com.xinyue.user.utils;


import java.util.Date;
import java.util.Random;


import org.springframework.web.multipart.MultipartFile;

public class FileUtils {
	
	
	public static String getRandomFileName(MultipartFile file){
		//获取文件结尾名
		String filename = file.getOriginalFilename();
		String subfix = filename.substring(filename.indexOf("."));
		//获取三位随机数
		Random random = new Random();
		int num = random.nextInt(999);
		String str = String.format("%03d", num);
		//当前时间 组合
		String newfile = new Date().getTime()+str+subfix;
		return newfile;

	}
}

